{% extends "public/layout.html" %}
{% load static %}
{% block body%}

<h3 class="page-header">用户管理</h3>
<table class="table table-striped">
    <caption>
        <div class="col-md-8">
            <a  class="btn btn-primary" id="create-user-id">创建用户</a>
        </div>
        <div class="col-md-4">
            <form class="form-inline">
                <div class="form-group">
                    <div class="input-group">
                        <input type="text" name="search_username" value="{{ search_data }}" class="form-control" >
                    </div>
                </div>
                <button type="submit" class="btn btn-primary">搜索</button>
            </form>
        </div>
    </caption>
    <thead>
    <tr>
        <th>-</th>
        <th>用户名</th>
        <th>中文名</th>
        <th>email</th>
        <th>电话</th>
        <th>企业qq</th>
        <th>状态</th>
        <th>创建时间</th>
        <th>最后登陆时间</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {% for user_obj in object_list %}
    <tr>
        <td>{{ forloop.counter}}</td>
        <td>{{ user_obj.username }}</td>
        <td>{{ user_obj.profile.name}}</td>
        <td>{{ user_obj.email }}</td>
        <td>{{ user_obj.profile.phone }}</td>
        <td>{{ user_obj.profile.qq }}</td>
        <td class="status">
            {% if user_obj.is_active %}
            <span class="glyphicon glyphicon-ok-circle text-success"></span>正常
            {% else %}
            <span class="glyphicon glyphicon-warning-sign text-warning"></span>禁止
            {% endif %}
        </td>
        <td>{{ user_obj.date_joined|date:"Y-m-d H:i:s"}}</td>
        <td>{{ user_obj.last_login|date:"Y-m-d H:i:s" }}</td>
        <td>
            <div class="btn-group">
                <div class="btn-group">
                    <button class="btn btn-primary btn-sm dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
                        修改
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
                        <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
                        <li role="presentation"><a role="menuitem" tabindex="-1" href="" data='{"uid": "{{ user_obj.id }}", "username": "{{ user_obj.username }}" }' class="user_to_group">添加到指定组</a></li>
                    </ul>
                </div>
                {% if user_obj.is_active %}
                <button type="button" class="btn btn-sm btn-warning modify_user_status" status={{ user_obj.is_active|lower  }} data="{{ user_obj.id }}">禁用</button>
                {% else %}
                <button type="button" class="btn btn-info btn-sm modify_user_status" status={{ user_obj.is_active|lower }} data="{{ user_obj.id }}">开启</button>
                {% endif %}
            </div>
        </td>
    </tr>
    {% endfor %}
    </tbody>
</table>

{% include "public/pagination.html" %}

{% endblock %}
{% block js %}
<script src="{% static 'account/js/userlist.js' %}"></script>
{% endblock %}

